#ifndef BINDDEVICE_H
#define BINDDEVICE_H

#include <QSettings>
#include <QWidget>
#include <qserialport.h>

#include <QtBluetooth/agent.h>

namespace Ui {
class BindDevice;
}

class BindDevice : public QWidget
{
    Q_OBJECT

public:
    explicit BindDevice(QWidget *parent = nullptr);
    ~BindDevice();
private slots:
    void on_pb_close_clicked();

    void on_pb_next_clicked();

    void onDeviceDiscovered(const QBluetoothDeviceInfo &info);


    void on_pb_scan_clicked();

    void onScanFinished();
    void on_pb_RefreshSerial_clicked();

    void on_pb_OpenSerial_clicked();

    void on_pb_clearDevice_clicked();
    void readComDataSlot();
    void on_pb_bindDevice_clicked();

    void on_pb_reset_clicked();

private:
    Ui::BindDevice *ui;
    Agent m_agent;
    QSerialPort *serialPort;
    bool isClear;
    bool isBind;

private:
    void checkBluetooth();
    void initSettings();
    void initSerialPort();
    void refresh_serial();
};

#endif // BINDDEVICE_H
